package com.boom.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.boom.mapper.UserMapper;
import com.boom.pojo.User;
import com.boom.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;


    public User getUser(QueryWrapper<User> wrapper) {
        return userMapper.selectOne(wrapper);
    }


    @Override
    public IPage<User> getUserList(String userName, Integer userRole, Integer pageNo, int pageSize) {
        Page<User> page = new Page<>(pageNo, pageSize);
        IPage<User> iPage = userMapper.selectUserPage(page,userName,userRole);
        return iPage;
    }

    @Override
    public User getUserById(String id) {

        return userMapper.getUserById(id);
    }

    @Override
    public int insertUser(User user) {
        int i=userMapper.insert(user);
        return i;
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateById(user);
    }

    @Override
    public int deleteUser(int id) {

        return userMapper.deleteById(id);
    }


}
